#include <iostream>
using namespace std;
int main()
{
	double p[2010], c, r[2010] = {0};
	int tt[2010], m, n, i, e, j, cnt = 0;
	cin >> m;
	for(i = 0; i < m; i++){
		cin >> tt[i];
		cin >> p[tt[i]];
	}
	cin >> n;
	for(i = 0; i < n; i++){
		cin >> e >> c;
		for(j = 0; j < m; j++)
			r[tt[j] + e] += c * p[tt[j]];
	}
	for(i = 0; i < 2010; i++)
		if(r[i] != 0.0)
			tt[cnt++] = i;
	cout << cnt;
	for(i = cnt - 1; i >= 0; i--)
		printf(" %d %.1f", tt[i], r[tt[i]]);
	return 0;
}
